package com.ss.android.lockscreen.component;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.a;

import com.ss.android.lockscreen.bb;

import java.util.ArrayList;

public class LockScreenProvider extends ContentProvider {
    private static String a;
    private static UriMatcher b;

    public LockScreenProvider() {

    }

    private static int a(Uri arg5) {
        int v0 = 1;
        int v1 = -1;
        if (LockScreenProvider.b == null) {
            LockScreenProvider.b = new UriMatcher(v1);
            if (LockScreenProvider.a != null) {
                LockScreenProvider.b.addURI(LockScreenProvider.a, "lockscreen", 1);
            }
        }

        switch (LockScreenProvider.b.match(arg5)) {
            case 1: {
                break;
            }
            default: {
                v0 = v1;
                break;
            }
        }

        return v0;
    }

    private static Cursor a(String[] arg5, ArrayList arg6) {
        MatrixCursor v2 = new MatrixCursor(arg5);
        int v1 = 0;
        while (true) {
            if (v1 < arg6.size()) {
                Object v0 = arg6.get(v1);
                if (v0 != null && ((Object[]) v0).length == 1) {
                    v2.addRow(((Object[]) v0));
                    ++v1;
                    continue;
                }

                break;
            } else {
                return v2;
            }
        }

        Cursor v0_1 = null;
        return v0_1;

    }

    public int delete(@NonNull Uri arg2, @Nullable String arg3, @Nullable String[] arg4) {
        return 0;
    }

    @Nullable
    public String getType(@NonNull Uri arg2) {
        return null;
    }

    @Nullable
    public Uri insert(@NonNull Uri arg2, @Nullable ContentValues arg3) {
        return null;
    }

    public boolean onCreate() {
        if (this.getContext() != null) {
            LockScreenProvider.a = this.getContext().getPackageName() + ".lockscreen";
        }

        return true;
    }

    @Nullable
    public Cursor query(@NonNull Uri arg7, @Nullable String[] arg8, @Nullable String arg9, @Nullable String[] arg10, @Nullable String arg11) {
        Cursor v0_1;
        Cursor v2 = null;
        int v0 = 1;
        switch (LockScreenProvider.a(arg7)) {
            case 1: {
                if (this.getContext() != null) {
                    bb.a().a(this.getContext().getApplicationContext());
                    bb.a().b();
                    String[] v2_1 = new String[]{"setting_state"};
                    ArrayList v3 = new ArrayList();
                    Object[] v4 = new Object[1];
                    if (!android.support.design.a.B.b()) {
                        v0 = 0;
                    }

                    v4[0] = Integer.valueOf(v0);
                    v3.add(v4);
                    v0_1 = LockScreenProvider.a(v2_1, v3);
                } else {
                    v0_1 = v2;
                }

                break;
            }
            default: {
                v0_1 = v2;
                break;
            }
        }

        return v0_1;
    }

    public int update(@NonNull Uri arg5, @Nullable ContentValues arg6, @Nullable String arg7, @Nullable String[] arg8) {
        int v0 = -1;
        int v1 = 1;
        switch (LockScreenProvider.a(arg5)) {
            case 1: {
                if (this.getContext() != null && arg6 != null && (arg6.containsKey("setting_state"))) {
                    boolean v0_1 = arg6.getAsInteger("setting_state").intValue() == 1 ? true : false;
                    bb.a().a(this.getContext().getApplicationContext());
                    android.support.design.a.B.a(v0_1);
                    bb.a().b();
                    return v1;
                }

                v1 = v0;
                break;
            }
            default: {
                v1 = v0;
                break;
            }
        }

        return v1;
    }
}

